
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @Problem: 11559 - Event Planning
 * @author Cesar Augusto Meneses Guzman
 * @version "%I%, %U%"
 * @since 22 de Agosot de 2013
 */
public class EventPlanning {
    public static void main(String Args[]) throws FileNotFoundException, IOException {
        // Para leer desde teclado
//        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // Para leer desde archivo
        BufferedReader br = new BufferedReader( new FileReader( new File( "inEventPlanning.txt" ) ) );
        
        while(br.ready()) {
            String[] data = br.readLine().split("[ ]+");
            // the number of participants
            short N = Short.parseShort(data[0]);
            // the budget
            int B = Integer.parseInt(data[1]);
            // the number of hotels to consider
            short H = Short.parseShort(data[2]);
            // the number of weeks you can choose between
            short W = Short.parseShort(data[3]);
            
            for(short i = 0; i < H; i++) {
                short p = Short.parseShort(br.readLine());
                String[] data2 = br.readLine().split("[ ]+");
                
                short[] a_s = new short[data2.length];
                for(short j = 0; j < data2.length; j++) {
                    a_s[j] = Short.parseShort(data2[j]);
                }
                boolean isGo = false;
                for (short j = 0; j < W; j++) {
                    int total = N * p * a_s[j];
                    if (total <= B) {
                        isGo = true;
                    } else if (j + 1 == W && isGo) {
                        System.out.println(total);
                    } else {
                        System.out.println("stay home");
                    }
                }
            }
        }
        br.close();
    }
}
